package com.gxufl.service;

import java.util.List;

import com.gxufl.Application;
import com.gxufl.dao.SeatDao;
import com.gxufl.dao.TicketDao;
import com.gxufl.entity.Ticket;
import com.gxufl.util.BackException;
import com.gxufl.util.JdbcUtil;

public class TicketService {
	TicketDao dao=new TicketDao();
	SeatDao seatDao=new SeatDao();
	
	public Ticket saveTicket(Ticket ticket) {
		boolean isok=seatDao.checkBeforeSaveTicket(ticket);
		if(!isok){
			System.out.println("票据验证不通过,座位以售出！");
			Application.fn显示售票录入();
			return null;
		}
		
		ticket=dao.save(ticket);
		return ticket;
	}
	
//	public void saveTicket(Ticket ticket){		
//			dao.save(ticket);
//	}
	
	//根据条件查询票据信息列表
	public List<Ticket> searchTicket(String noticeName, String roomName) {
		return dao.findList(noticeName, roomName);
	}	
	/**
	 * 通过用户手机号，查询票据信息
	 */
	public Ticket findOneByUsertel(String usertel) {
		return dao.findOneByUsertel(usertel);
	}

}
